package com.whosly.mysql.protocol.packet;

import io.netty.buffer.ByteBuf;

/**
 * @author fengyang
 * @date 2023/7/20 上午10:23
 * @see <a href="yueny09@163.com">mailTo: yueny09@163.com</a>
 */
public interface IMySQLPacket extends IMySQLReadPacket, MysqlPackConstants
{

    /**
     * 将 Packet 转为 ByteBuf, ByteBuf 自行分配与计算
     *
     * 不建议使用。建议通过如下方法实现：
     * writeBuf(ctx.alloc().buffer())
     */
    default ByteBuf writeBuf() {
        throw new UnsupportedOperationException();
    }

    /**
     * 将 Packet 转为 ByteBuf
     */
    default ByteBuf writeBuf(ByteBuf buffer) {
        throw new UnsupportedOperationException();
    }

    /**
     * 将 body bytes 解析为 Packet
     */
    default void read(byte[] bodyBytes) {
        throw new UnsupportedOperationException();
    }


}
